package cn.lasse.springframework.bean;

import cn.lasse.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class UserDao {
    /**
     * 假装数据库
     */
    private static Map<String, String> mysqlMap = new HashMap<>();


    public void initDataMethod(){
        System.out.println("UserDao执行：init-method");
        mysqlMap.put("10001", "穗爷");
        mysqlMap.put("10002", "八杯水");
        mysqlMap.put("10003", "阿毛");
    }

    public void destroyDataMethod(){
        System.out.println("UserDao执行：destroy-method");
        mysqlMap.clear();
    }

    public String queryUserNameById(String uId) {
        initDataMethod();
        return mysqlMap.get(uId);
    }
}
